<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
	"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
	xmlns:h="http://xmlns.jcp.org/jsf/html"
	xmlns:f="http://xmlns.jcp.org/jsf/core"
	xmlns:p="http://primefaces.org/ui">

<ui:composition template="/template.xhtml">
	<ui:define name="title">
		SGMF :: Relatório de Ordem de Serviço
	</ui:define>

	<ui:define name="content">
		<p:fieldset legend="Buscar Ordem de Serviço">
			<h:form id="search">
				<p:panelGrid columns="7" styleClass="borderless">
					<p:outputLabel value="Data de Cadastro Início" for="inicio" />
					<p:calendar id="inicio" value="#{relatorioOrdemServicoBean.inicio}" />
					<p:outputLabel value="Data de Cadastro Fim" for="fim" />
					<p:calendar id="fim" value="#{relatorioOrdemServicoBean.fim}" />
					<p:outputLabel value="Status" for="status" />
					<p:selectOneMenu id="status" value="#{relatorioOrdemServicoBean.statusOS}">
						<f:selectItem itemValue="#{null}" itemLabel="-- Nenhum --" />
						<f:selectItems value="#{relatorioOrdemServicoBean.statusesOS}" var="statusOS" itemValue="#{statusOS}" itemLabel="#{statusOS.statusOS}" />
					</p:selectOneMenu>
					<p:commandButton id="buscar" value="Buscar"
						actionListener="#{relatorioOrdemServicoBean.buscar}"
						update=":result_form:result" icon="ui-icon-search" ajax="false" />
				</p:panelGrid>
			</h:form>
		</p:fieldset>
		<br />
		<h:form id="result_form">
			<p:commandButton id="gerarRelatorio" value="Gerar Relatório" process="@this" icon="ui-icon-note" rendered="#{not empty relatorioOrdemServicoBean.ordensServico}" ajax="false">
				<p:dataExporter type="pdf" target="result" fileName="ordem_servico" preProcessor="#{relatorioOrdemServicoBean.preProcessPDF}" />
			</p:commandButton>
			<br />
			<br />
			<p:dataTable id="result" var="ordemServico"
			value="#{relatorioOrdemServicoBean.ordensServico}" rows="10" paginator="true"
			paginatorTemplate="{CurrentPageReport} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} "
			currentPageReportTemplate="({currentPage} de {totalPages})"
			emptyMessage="Nenhum registro encontrado."
			rendered="#{relatorioOrdemServicoBean.ordensServico != null}">
				<p:column headerText="Data de Cadastro">
					<h:outputText value="#{ordemServico.data}">
						<f:convertDateTime dateStyle="medium" />
					</h:outputText>
				</p:column>
				<p:column headerText="Número">
					<h:outputText value="#{ordemServico.numero}" />
				</p:column>
				<p:column headerText="Placa do Veículo">
					<h:outputText value="#{ordemServico.veiculo.placa}" />
				</p:column>
				<p:column headerText="Status">
					<h:outputText value="#{ordemServico.statusOS.statusOS}" />
				</p:column>
				<p:column headerText="Problema">
					<h:outputText value="#{ordemServico.problema}" />
				</p:column>
				<p:column headerText="Data de Previsão">
					<h:outputText value="#{ordemServico.previsao}">
						<f:convertDateTime dateStyle="medium" />
					</h:outputText>
				</p:column>
			</p:dataTable>
		</h:form>
	</ui:define>
</ui:composition>

</html>